package com.yjd.pub.job.service;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import com.yjd.comm.base.enums.DbWREnums;
import org.springframework.stereotype.Service;

import com.yjd.comm.base.dao.IBaseDao;
import com.yjd.comm.base.service.impl.BaseServiceImpl;
import com.yjd.comm.job.model.JobModel;
import com.yjd.comm.job.service.IJobService;
import com.yjd.pub.job.dao.IJobDao;

/**
 * <b>description</b>：后台JOB管理业务实现<br>
 * <b>time</b>：2017-08-14 13:04:44 <br>
 * <b>author</b>：  yangchangyan@yijiedai.com
 */
@Service("jobService")
public class JobServiceImpl extends BaseServiceImpl implements IJobService {

	/**
	 * 插入
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public JobModel insert(JobModel model) throws Exception {
		return this.jobDao.insertModel(model, true);
	}

	/**
	 * 更新
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public int update(JobModel model) throws Exception {
		return this.jobDao.updateModel(model, true);
	}

	/**
	 * 根据id删除
	 * 
	 * @param id_job
	 * @return
	 * @throws Exception
	 */
	public int delete(long id_job) throws Exception {
		Map<Object, Object> paramMap = new HashMap<Object, Object>();
		paramMap.put("id_job", id_job);
		return this.jobDao.deleteModel(paramMap, true);
	}

	@Override
	public JobModel getJobModelByType(String type) throws Exception {
		Map<Object, Object> paramMap = new HashMap<Object, Object>();
		paramMap.put("type", type);
		return this.getModelOne(paramMap, DbWREnums.READ);
	}

	@Resource
	private IJobDao jobDao;

	@Override
	public IBaseDao getBaseDao() {
		return this.jobDao;
	}

}
